// @ts-ignore
/* eslint-disable */
import request from '@/request'

/** 解密AES POST /api/utils/aesDesEn */
export async function aesDesEnUsingPost(
  body: Record<string, any>,
  options?: { [key: string]: any }
) {
  return request<API.BaseResponseString_>('/api/utils/aesDesEn', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  })
}

/** 加密AES POST /api/utils/aesEncrypt */
export async function aesEncryptUsingPost(
  body: Record<string, any>,
  options?: { [key: string]: any }
) {
  return request<API.BaseResponseString_>('/api/utils/aesEncrypt', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  })
}

/** 图片base64转图片 POST /api/utils/base64ToImage */
export async function base64ToImageUsingPost(
  body: Record<string, any>,
  options?: { [key: string]: any }
) {
  return request<any>('/api/utils/base64ToImage', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  })
}

/** 替换文件 POST /api/utils/fillTemplate */
export async function fillTemplateUsingPost(
  body: Record<string, any>,
  options?: { [key: string]: any }
) {
  return request<API.BaseResponseJSONObject_>('/api/utils/fillTemplate', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  })
}

/** 生产异常数据的POLICY_ID POST /api/utils/getPolicyMap */
export async function getPolicyMapUsingPost(options?: { [key: string]: any }) {
  return request<API.BaseResponseString_>('/api/utils/getPolicyMap', {
    method: 'POST',
    ...(options || {}),
  })
}

/** 哈希转字符串 POST /api/utils/hexToString */
export async function hexToStringUsingPost(
  body: Record<string, any>,
  options?: { [key: string]: any }
) {
  return request<string>('/api/utils/hexToString', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  })
}

/** 爱国网异常数据录入 POST /api/utils/importExceptions */
export async function importExceptionsUsingPost(
  body: {},
  file?: File,
  options?: { [key: string]: any }
) {
  const formData = new FormData()

  if (file) {
    formData.append('file', file)
  }

  Object.keys(body).forEach((ele) => {
    const item = (body as any)[ele]

    if (item !== undefined && item !== null) {
      if (typeof item === 'object' && !(item instanceof File)) {
        if (item instanceof Array) {
          item.forEach((f) => formData.append(ele, f || ''))
        } else {
          formData.append(ele, JSON.stringify(item))
        }
      } else {
        formData.append(ele, item)
      }
    }
  })

  return request<API.BaseResponseString_>('/api/utils/importExceptions', {
    method: 'POST',
    data: formData,
    requestType: 'form',
    ...(options || {}),
  })
}

/** 解密SM4 POST /api/utils/sm4Decrypt */
export async function sm4DecryptUsingPost(
  body: Record<string, any>,
  options?: { [key: string]: any }
) {
  return request<API.BaseResponseString_>('/api/utils/sm4Decrypt', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  })
}

/** 加密SM4 POST /api/utils/sm4Encrypt */
export async function sm4EncryptUsingPost(
  body: Record<string, any>,
  options?: { [key: string]: any }
) {
  return request<API.BaseResponseString_>('/api/utils/sm4Encrypt', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  })
}

/** 字符串转哈希 POST /api/utils/stringToHex */
export async function stringToHexUsingPost(
  body: Record<string, any>,
  options?: { [key: string]: any }
) {
  return request<string>('/api/utils/stringToHex', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  })
}

/** 上传替换模板 POST /api/utils/uploadTemplate */
export async function uploadTemplateUsingPost(
  body: {},
  file?: File,
  options?: { [key: string]: any }
) {
  const formData = new FormData()

  if (file) {
    formData.append('file', file)
  }

  Object.keys(body).forEach((ele) => {
    const item = (body as any)[ele]

    if (item !== undefined && item !== null) {
      if (typeof item === 'object' && !(item instanceof File)) {
        if (item instanceof Array) {
          item.forEach((f) => formData.append(ele, f || ''))
        } else {
          formData.append(ele, JSON.stringify(item))
        }
      } else {
        formData.append(ele, item)
      }
    }
  })

  return request<API.BaseResponseJSONObject_>('/api/utils/uploadTemplate', {
    method: 'POST',
    data: formData,
    requestType: 'form',
    ...(options || {}),
  })
}
